<script>
    $(document).ready(function(){
        <{if $opt eq 1}>
            $('#password').prop('required',true);
            <{/if}>
    });
    $('#nodeForm').submit(function () {

        <{if $opt eq 1}>
        var postUrl="<{u('Dev/SysUser/insert')}>";
        <{else}>
        var postUrl="<{u('Dev/SysUser/update')}>";
        <{/if}>

        $.post(postUrl,$('#nodeForm').serialize(),function(result){
            if(result.status==0){
                layer.msg("操作成功");
                LoadAjaxContent("<{U('Dev/SysUser/index')}>");
            }else{
                layer.msg(result.msg);
            }
        },'json');
        return false;
    });
</script>
<div class="box">
    <div class="box-content">
        <fieldset>
            <legend>账号管理-<{if $opt eq 1}>添加<{else}>修改<{/if}></legend>
            <form id="nodeForm" style="margin: 1em" class="form-horizontal">
                <input type="hidden" value="<{$obj['id']}>" name="id"/>
                <div class="form-group">
                    <label class="col-sm-1 control-label">姓名</label>
                    <div class="col-sm-2"><input type="text" class="form-control" value="<{$obj['real_name']}>" name="real_name" placeholder="输入姓名" required/></div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">登陆账号</label>
                    <div class="col-sm-2"><input type="text" class="form-control" value="<{$obj['username']}>" name="username" placeholder="输入登陆账号" required/></div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">登陆密码</label>
                    <div class="col-sm-2"><input type="password" id="password" placeholder="输入密码"  class="form-control" name="password" /></div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label">所属角色</label>
                    <div class="col-sm-2">
                        <select name="role_id" class="form-control">
                            <{foreach from="$role_list" item="v"}>
                            <option value="<{$v.id}>" <{if $obj['role_id'] == $v.id}> selected="selected" <{/if}>><{$v['remark']}></option>
                            <{/foreach}>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label">状态</label>
                    <div class="radio-inline">
                        <label>
                            <input type="radio" value="1" name="status" <{if $obj.status == 1}> checked <{/if}> > 启用
                            <i class="fa fa-circle-o"></i>
                        </label>
                    </div>
                    <div class="radio-inline">
                        <label>
                            <input type="radio" value="0" name="status" <{if $obj.status == 0}> checked <{/if}>> 禁用
                            <i class="fa fa-circle-o"></i>
                        </label>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-1 control-label">管理游戏</label>
                    <{foreach from=$games key=key item=item}>
                        <div class="checkbox-inline">
                            <label>
                                <input type="checkbox" value="<{$key}>" name="games[]"
                                <{foreach from=$selectedGame item=game}>
                                <{if  $game eq $key}> checked <{/if}>
                                <{/foreach}>

                                /> <{$item}>
                                <i class="fa fa-square-o"></i>
                            </label>
                        </div>
                    <{/foreach}>
                </div>

                <div class="form-group">
                    <div class="col-sm-1 "></div>
                    <div class="col-sm-2">
                        <button type="submit" id="submit" class="btn btn-primary btn-label-left"><span><i
                                class="fa fa-clock-o"></i></span>提交
                        </button>
                    </div>
                </div>
            </form>
        </fieldset>
    </div>
</div>